#pragma once

#include <QGraphicsItem>

using namespace std;
class Title;
class Node;
class mainClass;
class QGraphicsSceneMouseEvent;
class SceneView;
class TreeModel;
class QTreeView;

class Container : public QObject, public QGraphicsItem
{
	Q_OBJECT
public:
	static const enum Type { NPZ, RVS, AZS, CountType, VIRTUAL};
	Container(SceneView *_parentScene, Type _type, bool _visibleTitle = true);
	~Container();
	QRectF boundingRect() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void addTitle(Title *_title);
	void addNode(Node *node);
	void setEnabled(bool b);
	bool enabled();
	void initModel();
	void setSelectrable(bool s);
	Type type;
	QList<Node*> nodeList;
	Title *title;
	QRectF size;
	TreeModel* model;
protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *event);
	void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
	void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
	QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
	bool visibleTitle;
	bool resize;
	bool enable;
	bool accepted;
	QPointF minRBPoint;
	SceneView *parentScene;
	void calcMinRBPoint();
	void changeSize(QPointF _pos);
private slots:
		void getModelData(QString name, int posX, int posY, int sizeW, int sizeH, bool dispTitle);
		void updateTree();
signals:
		void setModelData(QString name, int posX, int posY, int sizeW, int sizeH, bool dispTitle);
		void setModelPos(int, int);
};
